/*! \file codevisitor.h
	\author HiddenSeeker
	
	A visitor that visits all classes and generates a code
 */
#include "../semantics/methodvisitor.h"
#pragma once


struct AttrInfo;
class ClassCode;

class CodeVisitor: public MethodVisitor
{
private:
	int  attribute_length_offset;
	int  code_length_offset;
	void writeMainCode(ClassCode & attrs);
	void createRootMethod();
	void createConstructor();
	void produceMethodCode();
	void startMethodDefinition(AttrInfo & methodInf,unsigned short attrs,int maxlocal,bool  isAbstract, bool hasSignature);
	void finishMethodDefinition(bool  isAbstract, bool hasSignature, unsigned short signature, unsigned short sigIndex);
public:
	inline CodeVisitor()
	{
			
	}
	/*! Action, performed after visiting class
	 */
	virtual void postVisitClass();
	virtual void visitClass();
	virtual void visitMethod();
	/*! Action, that is performed on visiting field
	 */
	virtual void visitField();
	/*! Action, performed befor visiting methods 
	 */
	virtual void preMethods();
	/*! Action, performed before visiting fields 
	 */
	virtual void preFields();
};